/**
 * @param {string} word1
 * @param {string} word2
 * @return {string}
 */
var mergeAlternately = function (word1, word2) {
    let w1 = word1.split("")
    let w2 = word2.split("")
    let ans = []
    while(w1.length>0&&w2.length>0){
        ans.push(w1.shift());
        ans.push(w2.shift());
    }
    // console.log(w1.length==false);
    ans = w1.length?ans.concat(w1):ans.concat(w2)
    return ans.join("")
};
mergeAlternately = function (word1, word2) {
    debugger
    let l1 = word1.length
    let l2 = word2.length
    min = l1<l2?l1:l2
    let ans = ""
    for(let i=0;i<min;i++){
        ans+=word1.charAt(i);
        ans+=word2.charAt(i);
    }
    ans += l1<l2?word2.slice(min):word1.slice(min)
    return ans
};
console.log(mergeAlternately("abc","pqrs"))